package cn.edu.cdu.argorithm.impl;

import cn.edu.cdu.argorithm.IRemoveDuplicatesFromSortedArray;

import java.util.LinkedList;
import java.util.Queue;

public class RemoveDuplicatesFromSortedArray {
    public static class Solution1 implements IRemoveDuplicatesFromSortedArray {
        @Override
        public int removeDuplicates(int[] nums) {
            int slow = 1, fast = 1, n = nums.length;
            while (fast < n) {
                if (nums[slow - 1] != nums[fast]) {
                    nums[slow++] = nums[fast];
                }
                fast++;
            }
            return slow;
        }
    }

    public static void main(String[] args) {
        int[] nums = {0,0,1,1,1,2,2,3,3,4};
        Solution1 solution1 = new Solution1();
        int i = solution1.removeDuplicates(nums);
        for (int j = 0; j < nums.length; j++) {
            System.out.print(nums[j]);
            System.out.print(",");
        }
        System.out.println();
        System.out.println(i);
    }

}
